<?php

use think\console\Input;
use think\console\Output;
use app\api\model\Transfers as TransfersModel;
use app\common\library\wechat\WxPay;
use app\api\model\Wxapp as WxappModel;

/**
 * Created by PhpStorm.
 * User: xiewenfeng
 * Date: 2020/9/28
 * Time: 22:19
 */
class TransfersCommand extends \think\console\Command
{
    protected function configure()
    {
        $this->setName('cron:transfers')->setDescription('this is a transfers check crontab!');
    }

    protected function execute(Input $input, Output $output)
    {
        //处理中的提现
        $transfers = TransfersModel::where(['status' => 'PROCESSING'])->order("create_time asc")->select();
        if ($transfers) {
            $wxConfig = WxappModel::getWxappCache('10001');
            $WxPay = new WxPay($wxConfig);
            foreach($transfers as $tr){
                $res = $WxPay->search_transfers($tr->trade_no);
                var_dump($res);
            }
        }
    }
}
